#ifndef _VSPAGE_H_
#define _VSPAGE_H_

#include <gtk/gtkdrawingarea.h>
#include <glib/poppler.h>

#define TYPE_VSPAGE (vspage_get_type ())
#define VSPAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VSPAGE, VSPage))

typedef struct {
	int x,y;
} Point;

typedef enum {
	ZOOM_TO_PAGE = 0,
	ZOOM_TO_WIDTH,
} ZoomMode ;

typedef struct _VSPage
{
	GtkDrawingArea parent;

	GdkPixmap *pixmap;
	PopplerRectangle selection; //in page coords

	PopplerPage *page;
	gdouble scale; //widget_size / page_size
	Point dst; //page render starting point

	ZoomMode zmode;
	GtkAdjustment *adj;
}VSPage;

typedef struct _VSPageClass
{
	GtkDrawingAreaClass parent;
	void (*set_scroll_adjustments)(VSPage*, GtkAdjustment*, GtkAdjustment*);
}VSPageClass;

GType vspage_get_type();
PopplerPage* vspage_get_page(VSPage *vspage);
void vspage_set_page(VSPage *vspage, PopplerPage* page);
void vspage_get_selection(VSPage *vspage, PopplerRectangle *selection);
void vspage_set_selection(VSPage *vspage, PopplerRectangle *selection);
void vspage_set_zoom_mode(VSPage *vspage, ZoomMode new_mode);
ZoomMode vspage_get_zoom_mode(VSPage *vspage);

static inline int vspage_get_page_index(VSPage *vspage)
{
	PopplerPage *page = vspage_get_page(vspage);
	return poppler_page_get_index(page);
}

#endif //_VSPAGE_H_
